package cn.hxlc.tie.demo.core.enums;

import cn.hxlc.tie.libs.scanner.stereotype.EnumResource;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;

@EnumResource
public enum TypeEnum implements IEnum<Integer> {
    NORMAL(0, "正常"),
    ABDM(1, "报废"),
    ;
    @EnumValue
    private final int code;
    private final String descp;

    @Override
    public Integer getValue() {
        return this.code;
    }

    @Override
    public String toString() {
        return this.descp;
    }

    TypeEnum(final int code, final String descp) {
        this.code = code;
        this.descp = descp;
    }

    public static TypeEnum toEnum(Integer code) {
        if (null != code) {
            for (TypeEnum e : TypeEnum.values()) {
                if (e.getCode()==code) {
                    return e;
                }
            }
        }
        return null;
    }


    public int getCode() {
        return code;
    }
}
